//package cn.xie.blog.servergateway.handler;
//
//import cn.xie.blog.model.common.enums.response.ResponseCodeEnum;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import jakarta.annotation.Resource;
//import jakarta.servlet.ServletException;
//import jakarta.servlet.ServletOutputStream;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.AuthenticationEntryPoint;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.nio.charset.StandardCharsets;
//
///**
// * @description: 未登录处理器
// * @author: xiaoxie
// * @date: 2025/4/30 上午11:04
// **/
//@Component
//public class LoginAuthenticationHandler implements AuthenticationEntryPoint {
//
//    private final Logger logger = LoggerFactory.getLogger(LoginAuthenticationHandler.class);
//    @Resource
//    private  ObjectMapper objectMapper;
//
//    @Override
//    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
//        logger.info("请求需要认证：{}", request.getRequestURI());
//        logger.debug("异常：{}", authException.getMessage());
//
//        response.setContentType("application/json;charset=UTF-8");
//        ServletOutputStream out = response.getOutputStream();
//        out.write(objectMapper.writeValueAsString(ResponseCodeEnum.LOGIN_AUTH).getBytes(StandardCharsets.UTF_8));
//        out.flush();
//        out.close();
//    }
//}